package com.rp.demo;

import com.opencsv.CSVReader;
import com.rp.pojo.User;

import java.io.File;
import java.io.FileReader;
import java.text.SimpleDateFormat;

public class CSVDemo {
    public static void main(String[] args) throws Exception{

        System.out.println("----");

        CSVReader csvReader = new CSVReader(new FileReader("/Users/rp/Downloads/使用csv文件导出百万数据.csv"));
        String[] titles = csvReader.readNext();

        User user = null;

        while (true){
            user = new User();
            String[] content = csvReader.readNext();
            if(content == null){
                break;
            }
            user.setId(Long.valueOf(content[0]));
            user.setUserName(content[1]);
            user.setPhone(content[2]);
            user.setHireDate(new SimpleDateFormat("yyyy-MM-dd").parse(content[3]));
            user.setAddress(content[4]);
            System.out.println(user);

        }

    }
}
